{template 'header'}
<link href="./resource/css/app.css" rel="stylesheet">
<ul class="nav nav-tabs">
    <li class="active"><a href="{php echo $this->createWeburl('luck');}">奖品列表</a></li>
</ul>
<div class="panel panel-default">
    <div class="table-responsive panel-body">
        <table class="table table-hover">
            <thead class="navbar-inner">
            <tr>
                <th>id</th>
                <th>类型</th>
                <th>金额</th>
                <th>抽奖商品</th>
                <th>是否指定</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
            {loop $luckGoodsDetails $item}
            <tr class="odd gradeX">
                <td>{$item['id']}</td>
                <td>{$item['type']}</td>
                <td>{$item['money']}</td>
                <td>{$item['name']}</td>
                <td>{php echo $item['is_appoint'] ==1 ? '不指定' : '指定'}</td>
                <td>
                    {if $item['is_appoint'] == 2}
                    <a href="{php echo $this->createWeburl('checkGoodsDetails', array('op' => 'cancel','luck_id'=>$item['luck_id'], 'goods_id' => $item['id']));}" class="btn btn-danger btn-sm">取消</a>
                    {else}
                    <a href="{php echo $this->createWeburl('luckAssign', array('luck_goods_info_id' => $item['id'] ,'luck_id'=>$item['luck_id']));}" class="btn btn-success btn-sm">指定</a>
                    {/if}
                </td>
            </tr>
            {/loop}
            </tbody>
        </table>
    </div>

</div>
{template 'footer'}
<script type="application/javascript">
    $(function () {
        $('.delete').click(function () {
            if (!confirm('确认要删除此分类?')) {
                return false;
            }
            id = $(this).attr('id');
            $.post('', {id:id, op:'delete'}, function (data) {
                if (data.status == 1) {
                    location.href = location.href;
                } else {
                    alert('删除失败');
                }

            }, 'json')
        });


        $('.sort').blur(function () {
            var sort = $(this).val();
            var  id = $(this).data('id');
            $.post('', {id:id,sort:sort, op:'sort'}, function (data) {
                if (data.status == 1) {
                    location.href = location.href;
                } else {
                    alert('排序失败');
                }

            }, 'json')
        });

        $('.settop').click(function () {
            id = $(this).data('id');
            $.post('', {id:id, op:'settop'}, function (data) {
                if (data.status == 1) {
                    location.href = location.href;
                } else {
                    alert('删除失败');
                }

            }, 'json')
        });
    });

</script>